package com.nwpu.am.mapper;

import com.github.pagehelper.Page;
import com.nwpu.am.pojo.dto.page.OrderPageDTO;
import com.nwpu.am.pojo.entity.Order;
import org.apache.ibatis.annotations.*;


import java.time.LocalDateTime;
import java.util.ArrayList;


@Mapper
public interface OrderMapper {
    @Insert("INSERT INTO tb_order (order_id, create_time, user_id, status, pay_money, complete_time, description,owner_name,owner_tel) VALUES (#{orderId}, #{creatTime}, #{userId}, #{status}, #{payMoney}, #{completeTime}, #{description},#{ownerName},#{ownerTel})")
    void insertOrder(Order order);

    @Select("SELECT * FROM tb_order WHERE order_id = #{orderId}")
    Order selectOrderById(Long orderId);

    int updateOrder(@Param("orderId") Long orderId,@Param("payMoney") int payMoney,@Param("description") String description, @Param("ownerName") String ownerName,@Param("ownerTel")String ownerTel);


    @Delete("DELETE FROM tb_order WHERE order_id = #{orderId}")
    void deleteOrderById(Long orderId);
    @Select("SELECT * FROM tb_order")
    ArrayList<Order> selectAll();
    @Update("UPDATE tb_order SET status =#{status}, complete_time =#{completeTime} WHERE order_id =#{orderId}")
    void orderFinished(@Param("orderId") Long orderId, @Param("completeTime") LocalDateTime completeTime,@Param("status")short status);
    @Select("SELECT * FROM tb_order")
    Page<Order> pageQuery(OrderPageDTO orderPageDTO);
}
